package wzt.com.JiaBangMang.netManagementServer;

import wzt.com.JiaBangMang.netProtocol.ClientToServerProtocolObject;
import wzt.com.JiaBangMang.netProtocol.NetCmdObject.INetCmdExecute;
import wzt.com.JiaBangMang.netProtocol.NetCmdObject.INetCmdExecuteResult;
import wzt.com.JiaBangMang.netProtocol.NetCmdObject.NetCmdType;
import wzt.com.JiaBangMang.netProtocol.NetCmdObject.NetLoginUser;
import wzt.com.JiaBangMang.netProtocol.NetCmdObject.NetRegisterUser;

public class AnalyzeCmdObject implements IAnalyzeObject{
	private ClientToServerProtocolObject cmdObject = null;
	public AnalyzeCmdObject(ClientToServerProtocolObject obj)
	{
		this.cmdObject = obj;
	}
	
	@Override
	public INetCmdExecuteResult Analyze()
	{
		INetCmdExecute execute = new MGServerCmdExecute();
		switch(this.cmdObject.getCmd())
		{
		case NetCmdType.NET_CMD_REGISTER_USER:
			NetRegisterUser regInfo = (NetRegisterUser)this.cmdObject.getCmdobj();
			return execute.RegisterUser(regInfo);
		case NetCmdType.NET_CMD_LOGIN_USER:
			NetLoginUser loginInfo = (NetLoginUser)this.cmdObject.getCmdobj();
			return execute.LoginUser(loginInfo);
		}
		return null;
	}

	public ClientToServerProtocolObject getCmdObject() {
		return cmdObject;
	}
	
}
